feat: improve plugin json error recovery - #30
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the APISIX plugin JSON editing experience in the Dashboard by making JSON save failures easier to notice and recover from, and adds Playwright coverage for invalid JSON recovery on plugin metadata.
Changes:
- Moves plugin JSON save error alerts above the editor and adds “Format JSON” / “Reset JSON” recovery actions directly on the error alert.
- Exposes a global Monaco editor handle in
FormItemEditorduring dev/test to support E2E interaction. - Extends the plugin metadata CRUD E2E spec to cover invalid JSON recovery before saving a valid payload.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/components/form/Editor.tsx | Updates Monaco onMount logic to optionally expose the editor instance on window in dev/test contexts. |
| src/components/form-slice/FormItemPlugins/PluginEditorDrawer.tsx | Adds inline recovery actions to the JSON save error alert and repositions the alert above the editor area. |
| e2e/tests/plugin_metadata.crud-all-fields.spec.ts | Adds a new invalid-JSON recovery flow to the plugin metadata CRUD Playwright test. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+79
to
+85
| await page.evaluate(() => { | ||
| window.__monacoEditor__?.getModel()?.setValue('{'); | ||
| }); | ||
| await page.waitForFunction( | ||
| () => window.__monacoEditor__?.getModel()?.getValue() === '{' | ||
| ); | ||
| await pluginEditor.blur(); |
Comment on lines
184
to
187
| onMount={(editor) => { | ||
| if (process.env.NODE_ENV === 'test') { | ||
| if (process.env.NODE_ENV === 'test' || import.meta.env.DEV) { | ||
| window.__monacoEditor__ = editor; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Verification